﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using CimeaSoft.BE;
using CimeaSoft.BL;
using Microsoft.Practices.Unity;

namespace CimeaSoft.UI
{
    public partial class FrmShowMuestreo : Telerik.WinControls.UI.RadForm
    {
        [Dependency]
        public IMuestraBL muestraBL { get; set; }

        public FrmShowMuestreo()
        {
            InitializeComponent();
            this.BuilUp();
        }

        private void FrmShowMuestreo_Load(object sender, EventArgs e)
        {
            muestraBindingSource.DataSource = muestraBL.GetAllFromMuestra();
        }

        private void btnBuscar_Click(object sender, EventArgs e)
        {
            muestraBindingSource.DataSource = muestraBL.GetAllFromMuestraByCriterio(txtCriterio.Text);
        }

        private void txtCriterio_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                muestraBindingSource.DataSource = muestraBL.GetAllFromMuestraByCriterio(txtCriterio.Text);
            }
        }

        private void btnReportes_Click(object sender, EventArgs e)
        {
            var currentMuestra = muestraBindingSource.Current as Muestra;

            if (currentMuestra != null)
            {
                Reportes.FrmReporteMuestra frm = new Reportes.FrmReporteMuestra();
                frm.ObtenerId(currentMuestra.Id);
                frm.ShowDialog();
            }
            else MessageBox.Show("Debe seleccionar una Muestra", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}
